package com.itheima.config;

import com.itheima.pojo.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <dl>
 * <dd>描述: ~节点业务逻辑实现</dd>
 * <dd>创建时间：  14:39 2020/4/22</dd>
 * <dd>创建人： zz</dd>
 * <dt>版本历史: </dt>
 * <pre>
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2020/4/22      guodong       1.0        1.0 Version
 * </pre>
 * </dl>
 */
@Configuration //声明是一个配置类
public class UserConfig {


   /* @Bean
    public Apple apple(){
        return new Apple();
    }*/

    //<bean id='user' />
    @Bean
    //通过 Conditional注解来进行条件判断，如果为true则创建userBean，false则不创建
    //@Conditional(ClassCondition.class)
    //@ConditionalOnMissingBean(Apple.class) //代表如果beanFactory没有apple bean则创建userBean
    //@ConditionalOnBean(Apple.class) //代表如果beanFactory有apple bean则创建userBean
    //itheima=364
    @ConditionalOnProperty(name = "itheima", havingValue = "364")
    public User user(){
        User user = new User();
        user.setName("张三");
        user.setAge(23);
        return user;
    }
}
